package com.training1.core.web.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.training1.core.common.controller.BaseController;
import com.training1.core.dto.TreeNodeDto;
import com.training1.core.modules.service.NodeService;
@Controller
@RequestMapping("tree")
public class TreeViewController extends BaseController{

	@Resource
	private NodeService nodeService;
	
	
	@RequestMapping({"","/"})
	public String view(ModelMap model,Integer id){
		model.put("id", id);
		return "tree/view";
	}
	
	@RequestMapping("view/{type}")
	@ResponseBody
	public List<TreeNodeDto> views(Integer id,@PathVariable Character type){
		List<TreeNodeDto> list = nodeService.listByTypeAndTreeIndex(id,type);
		return list;
	}
	
	
	
}
